package com.greensam.pixelengine.pojo.base;

import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author Macro_Ray
 * @since 2025/6/13 13:26
 */
@Data
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity implements Serializable {

    @Id
    @Column(length = 20)
    @Comment("主键标识")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 创建时间
     */
    @Comment("创建时间")
    @CreatedDate
    private LocalDateTime createTime;

    /**
     * 创建人
     */
    @Comment("创建人")
    @CreatedBy
    private Long createBy;

    /**
     * 更新时间
     */
    @Comment("更新时间")
    @LastModifiedDate
    private LocalDateTime updateTime;

    /**
     * 更新人
     */
    @Comment("更新人")
    @LastModifiedBy
    private Long updateBy;

    /**
     * 数据有效性 0 无效  1有效
     */
    @Column(name = "is_deleted")
    @Comment("逻辑删除")
    private Boolean delete = Boolean.FALSE;
}
